//
// Created by Administrator on 12/24/2017.
//

#include <stdio.h>
#include <string.h>

typedef unsigned char *byte_pointer;
void show_bytes(byte_pointer start, int len) {
    int i;
    for (int i = 0; i < len; ++i) {
        printf(" %.2x", start[len - i - 1]);
    }
    printf("\n");
}

void show_int(int x) {
    show_bytes((byte_pointer)&x, sizeof(int));
}

int fun1(unsigned word) {
    return (int) ((word << 24) >> 24);
}

int fun2(unsigned word) {
    return ((int) (word << 24)) >> 24;
}

int main() {
    show_int(fun1(0x00000076));
    show_int(fun2(0x00000076));

    show_int(fun1(0x87654321));
    show_int(fun2(0x87654321));

    show_int(fun1(0x000000C9));
    show_int(fun2(0x000000C9));

    show_int(fun1(0xEDCBA987));
    show_int(fun2(0xEDCBA987));

    unsigned i = 0;
    int j = i - 1;

    printf("%d", j);

}